<?php

namespace app\yunda\validate;
use think\Validate;
class Brokerage extends Validate
{
    //定义验证规则
    protected $rule = [
        'level|佣金级别' => 'require',
        'type|用户类型' => 'require|checkType',
        'money|佣金' => 'require|regex:^\d{1,2}.{0,1}\d{0,2}$',
    ];

    //定义验证提示
    protected $message = [
        'money.regex' => '请填写大于0的数字，最多保留两位小数',

    ];

    protected $scene=[
//        'edit'=>['config_value'=>'require',],
    ];

    protected function checkType($value,$rule,$data)
    {
        if($value==1){
            if(empty($data['hy_level'])) return $rule='会员等级不能为空';
            return $rule=true;
        }
    }

}
